<template>
    <view class="x-tabbar-placeholder pb-safe-area">
        <view class="x-tabbar pb-safe-area">
            <view class="x-tabbar-item" v-for="(item, index) in GLOBALSTATUS.tabbar" :key="index"
                :class="{ 'x-tabbar-item-active': props.page && item.url.includes(props.page) }" @tap="$page.ads(item)">
                <image :src="props.page && item.url.includes(props.page) ? (item.image_2 || item.image) : item.image"
                    class="x-tabbar-item-icon" />
                <text class="x-tabbar-item-text" v-if="props.page && item.url.includes(props.page)"></text>
                <text class="x-tabbar-item-text" v-else>{{ item.title }}</text>
            </view>
        </view>
    </view>
</template>
<script lang="ts" setup>
import { defineProps } from 'vue';
import { $page } from '@/utils';
import { useStatusStore, useRefs } from "@/stores";
const props = withDefaults(defineProps<{
    page?: string,
}>(), {
});
const statusStore = useStatusStore();
const { GLOBALSTATUS } = useRefs(statusStore);
</script>
<style lang="scss" scoped>
.x-tabbar-placeholder,
.x-tabbar {
    height: 100rpx;
    box-sizing: unset;
}

.x-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: $uni-bg-color;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: solid 1px #313131;

    &-item {
        --text-color: #919191;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 10rpx 0;

        &-icon {
            width: 48rpx;
            height: 48rpx;
        }

        &-text {
            font-size: 12px;
            color: var(--text-color);
        }

        &-active {
            .x-tabbar-item-text {
                background-color: var(--xl-primary);
                width: 30rpx;
                height: 8rpx;
                border-radius: 8rpx;
            }
        }
    }
}
</style>